﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Protocol.section;
using Pixysoft.Weblications.Sango.Dao;
using System.Data;
using Pixysoft.Weblications.Sango.Protocol;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Protocol.player;
using Pixysoft.Tools;
using Pixysoft.Weblications.Sango.Battle;

namespace Pixysoft.Weblications.Sango.Command.section_rvr
{
    partial class SangoSectionRvrHandler
    {
        public sectionrvr_teamlist sectionrvr_teamlist(long targetsectionserialcode)
        {
            string usercode = SangoManager.Authentication();

            sectionrvr_teamlist response = ReflectionManager.CreatePojo<sectionrvr_teamlist>();
            response.Succeed = false;

            Entities.Usr_Section section = UsrSectionDao.GetSection(usercode);
            Entities.Sys_Section sysSection = SysSectionHelper.searchSectionByCode(section.Sectionserialcode);
            Entities.Sys_Section targetSysSection = SysSectionHelper.searchSectionByCode(targetsectionserialcode);
            Entities.Cti_Section citySection = CitySectionHelper.searchSectionByCode(section.Sectionserialcode);
            Entities.Sys_Sectionbattle sysBattle = SysSectionBattleHelper.searchByFight(citySection.Fightwincount);


            RvrSectionTeam rvrTeam = RvrSectionController.Instance.GetSectionTeam(sysSection, targetSysSection);
            response.profiles = UsrSectionFacade.ToProfilesBySectionTeam(rvrTeam);

            response.fightcount = citySection.Fightwincount;
            response.totalfightcount = sysBattle.Fightwincount;
            response.fighttime = rvrTeam.Battledate;
            Entities.Cti_Section targetCitySection = CitySectionHelper.searchSectionByCode(targetsectionserialcode);
            response.targetsection = UsrSectionFacade.ToSection(targetSysSection, targetCitySection);

            response.roomcode = rvrTeam.Roomcode;
            response.hasbattle = RvrSectionController.Instance.HasJoinSectionTeam(usercode);
            response.Succeed = true;
            return response;
        }
    }

    public interface sectionrvr_teamlist : ISangoResponse
    {
        List<section_profile> profiles { get;set;}
        player_section targetsection { get;set;}

        long roomcode { get;set;}
        long fighttime { get;set;}
        long fightcount { get;set;}
        long totalfightcount { get;set;}

        bool hasbattle { get;set;}
    }
}
